home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Freeware / Miro 1.0 / Miro_Installer.exe / xulrunner / python / compiled_templates / channel_folder.py < prev    next >
Encoding:
Python Source  |  2007-11-12  |  32.0 KB  |  518 lines

  1. # This is a generated file. Do not edit.
  2. from template import Handle, fillAttr, quoteAndFillAttr, fillStaticTemplate
  3. from StringIO import StringIO
  4. from xhtmltools import urlencode
  5. from templatehelper import quoteattr, escape
  6. from string import Template
  7. import app
  8. import views
  9. import sorts
  10. import indexes
  11. import filters
  12. import resources
  13. import gtcache
  14. _ = gtcache.gettext
  15. def fillTemplate(domHandler, dtvPlatform, eventCookie, bodyTagExtra, *args, **kargs):
  16.     # Start of handle
  17.  
  18.     # Start user code
  19.     
  20.     
  21.     folder = views.channelFolders.getObjectByID(int(kargs['id']))
  22.     filters.switchNewItemsChannel(folder)
  23.     sorts.switchUnwatchedFirstChannel(folder)
  24.     
  25.     def showDownloadsFilter(x):
  26.         return showDownloads
  27.     
  28.     def showWatchableFilter(x):
  29.         return showWatchableItems
  30.     
  31.     def showNewFilter(x):
  32.         isNew = filters.newItems(x)
  33.         # need to make call newItems() so that the filter remembers if the item
  34.         # was flagged as new or not.
  35.         return showNewItems and (allItemsMode or isNew)
  36.     
  37.     def updateSearchString(newSearch):
  38.         global searchTerm
  39.         if len(newSearch) == 0:
  40.             searchTerm = None
  41.         else:
  42.             searchTerm = newSearch
  43.         allItems.recomputeFilters()
  44.     
  45.     def toggleDownloadsView(handle):
  46.         global showDownloads
  47.         showDownloads = not showDownloads
  48.         allDownloadingItems.recomputeFilter(downloadingItems)
  49.         handle.forceUpdate()
  50.     
  51.     def toggleWatchableView(handle):
  52.         global showWatchableItems
  53.         showWatchableItems = not showWatchableItems
  54.         allWatchableItems.recomputeFilter(watchableItems)
  55.         handle.forceUpdate()
  56.     
  57.     def toggleNewItemsView(handle):
  58.         global showNewItems
  59.         showNewItems = not showNewItems
  60.         matchingItems.recomputeFilter(newItems)
  61.         handle.forceUpdate()
  62.     
  63.     def toggleAllItemsMode(handle):
  64.         print "Toggling all items"
  65.         global allItemsMode
  66.         allItemsMode = not allItemsMode
  67.         matchingItems.recomputeFilter(newItems)
  68.         handle.forceUpdate()
  69.     
  70.     def setSortBy(by, which, handle):
  71.         if which == 'main':
  72.           folder.itemSort.setSortBy(by)
  73.           matchingItems.recomputeSort(newItems)
  74.         elif which == 'downloading':
  75.           feed.itemSortDownloading.setSortBy(by)
  76.           allDownloadingItems.recomputeSort(downloadingItems)
  77.         else:
  78.           folder.itemSortWatchable.setSortBy(by)
  79.           allWatchableItems.recomputeSort(watchableItems)
  80.         handle.forceUpdate()
  81.     
  82.     allFeeds = views.feeds.filterWithIndex(indexes.byFolder, folder)
  83.     
  84.     global searchTerm, showDownloads, showWatchableItems, showNewItems, allItemsMode
  85.     searchTerm = None
  86.     
  87.     # The main section
  88.     allItemsMode = False
  89.     
  90.     # Initial states of views in this template
  91.     showDownloads = False
  92.     showNewItems = True
  93.     showWatchableItems = True
  94.     
  95.     allItems = views.items.filterWithIndex(indexes.itemsByChannelFolder, folder)
  96.     notDeleted = allItems.filter(filters.notDeleted)
  97.     matchingItems = notDeleted.filter(lambda x: filters.matchingItems(x, searchTerm))
  98.     newItems = matchingItems.filter(showNewFilter, sortFunc=folder.itemSort.sort, resort=True)
  99.     
  100.     allDownloadingItems = matchingItems.filter(filters.downloadingOrPausedItems)
  101.     downloadingItems = allDownloadingItems.filter(showDownloadsFilter,sortFunc=folder.itemSortDownloading.sort,resort=True)
  102.     allWatchableItems = matchingItems.filter(filters.watchableItems)
  103.     watchableItems = allWatchableItems.filter(showWatchableFilter,sortFunc=folder.itemSortWatchable.sort, resort=True)
  104.     
  105.     thisFolderView = views.channelFolders.filter(lambda x: x is folder)
  106.     childrenView = views.feeds.filterWithIndex(indexes.byFolder, folder)
  107.     
  108.     # Make the channel-content template happy
  109.     thisFeedView = thisFolderView
  110.     feed = None
  111.     itemSort = folder.itemSort
  112.     itemSortDownloading = folder.itemSortDownloading
  113.     itemSortWatchable = folder.itemSortWatchable
  114.     
  115.     def allItemsHaveState(view, state):
  116.         for item in view:
  117.             if item.getState() != state:
  118.                 return False
  119.         return True
  120.     def allItemsPaused(view):
  121.         return allItemsHaveState(view, 'paused')
  122.     def allItemsDownloading(view):
  123.         return allItemsHaveState(view, 'downloading')
  124.     
  125.     showNewItems = (len(watchableItems) == 0) or len(newItems) > 0
  126.     
  127.     if len(newItems) == 0:
  128.         allItemsMode = True
  129.         matchingItems.recomputeFilter(newItems)
  130.     
  131.     for feed in allFeeds:
  132.         feed.updateIcons()
  133.     
  134.     isFolder = True
  135.     
  136.         
  137.  
  138.     def _execOnUnload():
  139.         
  140.         matchingItems.unlink()
  141.         thisFolderView.unlink()
  142.         notDeleted.unlink()
  143.         allItems.unlink()
  144.         for feed in allFeeds:
  145.             if feed.idExists():
  146.                 feed.markAsViewed()
  147.         
  148.             
  149.     # End user code
  150.  
  151.     localvars = locals()
  152.     localvars.update(globals())
  153.     handle = Handle(domHandler, localvars, onUnlink = _execOnUnload)
  154.  
  155.     def up_0_handle(viewName, view, tid):
  156.         out = StringIO()
  157.         out.write(u'<div id="')
  158.         out.write(quoteattr(tid))
  159.         out.write(u'">\n        <h1 id="main-title">')
  160.         out.write(escape(folder.getTitle()))
  161.         out.write(u'</h1>\n    </div>')
  162.         out.seek(0)
  163.         return out
  164.     handle.addUpdate('tmplcomp79163633','nextSibling',thisFolderView,up_0_handle, u'thisFolderView')
  165.     def up_1_handle(viewName, view, tid):
  166.         out = StringIO()
  167.         out.write(u'<div id="')
  168.         out.write(quoteattr(tid))
  169.         out.write(u'">\n')
  170.         if not (not (childrenView.len() == 0)):
  171.             out.write(u'<div>\n    <div class="channel-blank">\n    <div class="channel-message">')
  172.             out.write(_(u'Empty Channel Folder'))
  173.             out.write(u'</div>\n    <div class="channel-message small">')
  174.             out.write(_(u'Drag channels to this folder to add them.'))
  175.             out.write(u'</div>\n    </div>\n</div>')
  176.         out.write(u'\n</div>')
  177.         out.seek(0)
  178.         return out
  179.     handle.addUpdate('tmplcomp05902902','nextSibling',childrenView,up_1_handle, u'childrenView')
  180.     # Start of handle
  181.  
  182.     # Start user code
  183.     # End user code
  184.  
  185.     localvars = locals()
  186.     localvars.update(globals())
  187.     handle_0 = Handle(domHandler, localvars, onUnlink = lambda:None)
  188.  
  189.     def up_0_handle_0(viewName, view, tid):
  190.         out = StringIO()
  191.         out.write(u'<div id="')
  192.         out.write(quoteattr(tid))
  193.         out.write(u'">\n')
  194.         if not (allDownloadingItems.len() == 0):
  195.             out.write(u'<div>\n<div class="main-channelbar downloading-channelbar" onclick="return eventURL(\'action:toggleDownloadsView\');">\n  ')
  196.             if not (showDownloads):
  197.                 out.write(u'<div class="triangle"></div>')
  198.             out.write(u'\n  ')
  199.             if not (not showDownloads):
  200.                 out.write(u'<div class="triangle down"></div>')
  201.             out.write(u'\n  <a href="#" class="download-bar-action" onclick="eventURLAndStop(\'action:cancelDownloads\', event);">Cancel All</a>\n  ')
  202.             if not (allItemsPaused(allDownloadingItems)):
  203.                 out.write(u'<a href="#" class="download-bar-action" onclick="eventURLAndStop(\'action:pauseDownloads\', event);">Pause All</a>')
  204.             out.write(u'\n  ')
  205.             if not (allItemsDownloading(allDownloadingItems)):
  206.                 out.write(u'<a href="#" class="download-bar-action" onclick="eventURLAndStop(\'action:resumeDownloads\', event);">Resume All</a>')
  207.             out.write(u'\n  ')
  208.             if not (allDownloadingItems.len()==1):
  209.                 out.write(u'<span>\n      <span>')
  210.                 out.write(escape(allDownloadingItems.len()))
  211.                 out.write(u'</span> Downloading</span>')
  212.             out.write(u'\n   ')
  213.             if not (allDownloadingItems.len()!=1):
  214.                 out.write(u'<span>1 Downloading</span>')
  215.             out.write(u'\n</div>\n</div>')
  216.         out.write(u'\n</div>')
  217.         out.seek(0)
  218.         return out
  219.     handle_0.addUpdate('tmplcomp42456820','nextSibling',allDownloadingItems,up_0_handle_0, u'allDownloadingItems')
  220.     def up_1_handle_0(viewName, view, tid):
  221.         out = StringIO()
  222.         out.write(u'<div class="downloading-sort" id="')
  223.         out.write(quoteattr(tid))
  224.         out.write(u'">\n        ')
  225.         if not (downloadingItems.len() == 0):
  226.             out.write(u'<div>\n            ')
  227.             out.write(fillStaticTemplate(u'sort-bar', onlyBody=True, section='downloading', itemSort=itemSortDownloading))
  228.             out.write(u'\n        </div>')
  229.         out.write(u'\n    </div>')
  230.         out.seek(0)
  231.         return out
  232.     handle_0.addUpdate('tmplcomp44566956','nextSibling',downloadingItems,up_1_handle_0, u'downloadingItems')
  233.     def up_2_handle_0(viewName, view, tid):
  234.         out = StringIO()
  235.         out.write(u'<a href="#" class="main-channelbar available-channelbar" onclick="return eventURL(\'action:toggleNewItemsView\');" id="')
  236.         out.write(quoteattr(tid))
  237.         out.write(u'">\n        ')
  238.         if not (showNewItems):
  239.             out.write(u'<div class="triangle"></div>')
  240.         out.write(u'\n        ')
  241.         if not (not showNewItems):
  242.             out.write(u'<div class="triangle down"></div>')
  243.         out.write(u'\n\n        ')
  244.         if not (not (not isFolder)):
  245.             out.write(u'<div>\n            ')
  246.             if not (not (feed.inlineSearchTerm is None)):
  247.                 out.write(u'<div>\n                <span>')
  248.                 out.write(escape(notDeleted.len()))
  249.                 out.write(u'</span> \n                Items in this Channel\n            </div>')
  250.             out.write(u'\n            ')
  251.             if not (not (feed.inlineSearchTerm is not None)):
  252.                 out.write(u'<div>\n                ')
  253.                 if not (not (notDeleted.len() == matchingItems.len())):
  254.                     out.write(u'<div>\n                    All <span>')
  255.                     out.write(escape(matchingItems.len()))
  256.                     out.write(u'</span> \n                    Match This Search\n                </div>')
  257.                 out.write(u'\n                ')
  258.                 if not (notDeleted.len() == matchingItems.len()):
  259.                     out.write(u'<div>\n                    <span>')
  260.                     out.write(escape(matchingItems.len()))
  261.                     out.write(u'</span> \n                    Match This Search\n                </div>')
  262.                 out.write(u'\n            </div>')
  263.             out.write(u'\n        </div>')
  264.         out.write(u'\n\n        ')
  265.         if not (not (isFolder)):
  266.             out.write(u'<div>\n            <span>')
  267.             out.write(escape(notDeleted.len()))
  268.             out.write(u'</span> \n            Items in this Channel Folder\n        </div>')
  269.         out.write(u'\n    </a>')
  270.         out.seek(0)
  271.         return out
  272.     handle_0.addUpdate('tmplcomp17163270','nextSibling',matchingItems,up_2_handle_0, u'matchingItems')
  273.     def up_3_handle_0(viewName, view, tid):
  274.         out = StringIO()
  275.         out.write(u'<div id="')
  276.         out.write(quoteattr(tid))
  277.         out.write(u'">\n    ')
  278.         if not (not (showNewItems)):
  279.             out.write(u'<div class="available-sort">\n        ')
  280.             out.write(fillStaticTemplate(u'sort-bar', onlyBody=True, section='main', itemSort=itemSort))
  281.             out.write(u'\n    </div>')
  282.         out.write(u'\n</div>')
  283.         out.seek(0)
  284.         return out
  285.     handle_0.addUpdate('tmplcomp06046450','nextSibling',matchingItems,up_3_handle_0, u'matchingItems')
  286.     def up_4_handle_0(viewName, view, tid):
  287.         out = StringIO()
  288.         out.write(u'<div id="')
  289.         out.write(quoteattr(tid))
  290.         out.write(u'">  \n  ')
  291.         if not (allItemsMode or not showNewItems or newItems.len() == matchingItems.len()):
  292.             out.write(u'<div>\n      <a href="#" class="main-notification" onclick="return eventURL(\'action:toggleAllItemsMode\');">\n          ')
  293.             if not (isFolder):
  294.                 out.write(u'<span><span>')
  295.                 out.write(escape(matchingItems.len() - newItems.len()))
  296.                 out.write(u'</span> more on this channel >></span>')
  297.             out.write(u'\n          ')
  298.             if not (not (isFolder)):
  299.                 out.write(u'<span><span>')
  300.                 out.write(escape(matchingItems.len()))
  301.                 out.write(u'</span> items in this channel folder >></span>')
  302.             out.write(u'\n        </a>\n        <a href="#" class="main-notification-right" onclick="return eventURL(\'action:toggleAllItemsMode\');"> </a>\n     <br clear="left"></br>\n  </div>')
  303.         out.write(u'\n</div>')
  304.         out.seek(0)
  305.         return out
  306.     handle_0.addUpdate('tmplcomp78307766','nextSibling',matchingItems,up_4_handle_0, u'matchingItems')
  307.     def up_5_handle_0(viewName, view, tid):
  308.         out = StringIO()
  309.         out.write(u'<div id="')
  310.         out.write(quoteattr(tid))
  311.         out.write(u'">\n        ')
  312.         if not (len(allWatchableItems) == 0 or (not isFolder and feed.getURL().startswith('dtv:directoryfeed'))):
  313.             out.write(u'<a href="#" class="main-channelbar downloaded-channelbar" onclick="return eventURL(\'action:toggleWatchableView\')">\n            ')
  314.             if not (showWatchableItems):
  315.                 out.write(u'<div class="triangle"></div>')
  316.             out.write(u'\n            ')
  317.             if not (not showWatchableItems):
  318.                 out.write(u'<div class="triangle down"></div>')
  319.             out.write(u'\n            <span>')
  320.             tmplcomp82236068 = {}
  321.             tmplcomp49618827 = StringIO()
  322.             tmplcomp49618827.write(u'<span>')
  323.             tmplcomp49618827.write(escape(allWatchableItems.len()))
  324.             tmplcomp49618827.write(u'</span>')
  325.             tmplcomp49618827.seek(0)
  326.             tmplcomp82236068['len'] = tmplcomp49618827.read()
  327.             out.write(Template(_(u'${len} Downloaded')).substitute(tmplcomp82236068))
  328.             out.write(u'</span>\n        </a>')
  329.         out.write(u'\n    </div>')
  330.         out.seek(0)
  331.         return out
  332.     handle_0.addUpdate('tmplcomp24866162','nextSibling',allWatchableItems,up_5_handle_0, u'allWatchableItems')
  333.     def up_6_handle_0(viewName, view, tid):
  334.         out = StringIO()
  335.         out.write(u'<div id="')
  336.         out.write(quoteattr(tid))
  337.         out.write(u'">\n        ')
  338.         if not (len(watchableItems) == 0):
  339.             out.write(u'<div>\n            ')
  340.             out.write(fillStaticTemplate(u'sort-bar', onlyBody=True, section='watchable', itemSort=itemSortWatchable))
  341.             out.write(u'\n        </div>')
  342.         out.write(u'\n    </div>')
  343.         out.seek(0)
  344.         return out
  345.     handle_0.addUpdate('tmplcomp45222576','nextSibling',watchableItems,up_6_handle_0, u'watchableItems')
  346.     def rep_7_handle_0(this, viewName, view, tid):
  347.         out = StringIO()
  348.         out.write(u'\n<div dragsourcetype="')
  349.         out.write(quoteattr(this.getDragType()))
  350.         out.write(u'" selectArea="itemlist" drageffectdownloadeditem="move" dragdestdata="playlistitem-')
  351.         out.write(quoteattr(this.getID()))
  352.         out.write(u'" dragicon="video-tnail-')
  353.         out.write(quoteattr(viewName + str(this.getID())))
  354.         out.write(u'" selectID="')
  355.         out.write(quoteattr(this.getID()))
  356.         out.write(u'" class="main-video draggable ')
  357.         out.write(quoteattr(this.getSelectedState(view)))
  358.         out.write(u' ')
  359.         out.write(quoteattr(this.getMoreInfoState()))
  360.         out.write(u'" dragsourcedata="itemlist-')
  361.         out.write(quoteattr(this.getID()))
  362.         out.write(u'" onclick="return handleSelect(event);" selectViewName="')
  363.         out.write(quoteattr(urlencode(viewName)))
  364.         out.write(u'" onmousedown="return handleContextMenuSelect(event);" dragdesttype="')
  365.         out.write(quoteattr(viewName == 'playlistView' and 'downloadeditem' or ''))
  366.         out.write(u'" ondblclick="return handleDblClick(event, \'')
  367.         out.write(quoteattr(urlencode(viewName)))
  368.         out.write(u"', ")
  369.         out.write(quoteattr(urlencode(this.getID())))
  370.         out.write(u');" id="')
  371.         out.write(quoteattr(tid))
  372.         out.write(u'">\n    <div>')
  373.         out.write(this.getItemXML(viewName))
  374.         out.write(u'</div>\n</div>\n')
  375.         out.seek(0)
  376.         return out
  377.     handle_0.addView('tmplcomp26851151','containerDiv',downloadingItems,rep_7_handle_0, u'downloadingItems')
  378.     def rep_8_handle_0(this, viewName, view, tid):
  379.         out = StringIO()
  380.         out.write(u'\n<div dragsourcetype="')
  381.         out.write(quoteattr(this.getDragType()))
  382.         out.write(u'" selectArea="itemlist" drageffectdownloadeditem="move" dragdestdata="playlistitem-')
  383.         out.write(quoteattr(this.getID()))
  384.         out.write(u'" dragicon="video-tnail-')
  385.         out.write(quoteattr(viewName + str(this.getID())))
  386.         out.write(u'" selectID="')
  387.         out.write(quoteattr(this.getID()))
  388.         out.write(u'" class="main-video draggable ')
  389.         out.write(quoteattr(this.getSelectedState(view)))
  390.         out.write(u' ')
  391.         out.write(quoteattr(this.getMoreInfoState()))
  392.         out.write(u'" dragsourcedata="itemlist-')
  393.         out.write(quoteattr(this.getID()))
  394.         out.write(u'" onclick="return handleSelect(event);" selectViewName="')
  395.         out.write(quoteattr(urlencode(viewName)))
  396.         out.write(u'" onmousedown="return handleContextMenuSelect(event);" dragdesttype="')
  397.         out.write(quoteattr(viewName == 'playlistView' and 'downloadeditem' or ''))
  398.         out.write(u'" ondblclick="return handleDblClick(event, \'')
  399.         out.write(quoteattr(urlencode(viewName)))
  400.         out.write(u"', ")
  401.         out.write(quoteattr(urlencode(this.getID())))
  402.         out.write(u');" id="')
  403.         out.write(quoteattr(tid))
  404.         out.write(u'">\n    <div>')
  405.         out.write(this.getItemXML(viewName))
  406.         out.write(u'</div>\n</div>\n')
  407.         out.seek(0)
  408.         return out
  409.     handle_0.addView('tmplcomp33017135','containerDiv',newItems,rep_8_handle_0, u'newItems')
  410.     def rep_9_handle_0(this, viewName, view, tid):
  411.         out = StringIO()
  412.         out.write(u'\n<div dragsourcetype="')
  413.         out.write(quoteattr(this.getDragType()))
  414.         out.write(u'" selectArea="itemlist" drageffectdownloadeditem="move" dragdestdata="playlistitem-')
  415.         out.write(quoteattr(this.getID()))
  416.         out.write(u'" dragicon="video-tnail-')
  417.         out.write(quoteattr(viewName + str(this.getID())))
  418.         out.write(u'" selectID="')
  419.         out.write(quoteattr(this.getID()))
  420.         out.write(u'" class="main-video draggable ')
  421.         out.write(quoteattr(this.getSelectedState(view)))
  422.         out.write(u' ')
  423.         out.write(quoteattr(this.getMoreInfoState()))
  424.         out.write(u'" dragsourcedata="itemlist-')
  425.         out.write(quoteattr(this.getID()))
  426.         out.write(u'" onclick="return handleSelect(event);" selectViewName="')
  427.         out.write(quoteattr(urlencode(viewName)))
  428.         out.write(u'" onmousedown="return handleContextMenuSelect(event);" dragdesttype="')
  429.         out.write(quoteattr(viewName == 'playlistView' and 'downloadeditem' or ''))
  430.         out.write(u'" ondblclick="return handleDblClick(event, \'')
  431.         out.write(quoteattr(urlencode(viewName)))
  432.         out.write(u"', ")
  433.         out.write(quoteattr(urlencode(this.getID())))
  434.         out.write(u');" id="')
  435.         out.write(quoteattr(tid))
  436.         out.write(u'">\n    <div>')
  437.         out.write(this.getItemXML(viewName))
  438.         out.write(u'</div>\n</div>\n')
  439.         out.seek(0)
  440.         return out
  441.     handle_0.addView('tmplcomp41906179','containerDiv',watchableItems,rep_9_handle_0, u'watchableItems')
  442.     # Start of handle
  443.  
  444.     # Start user code
  445.     # End user code
  446.  
  447.     localvars = locals()
  448.     localvars.update(globals())
  449.     handle_0_0 = Handle(domHandler, localvars, onUnlink = lambda:None)
  450.  
  451.     handle_0.addSubHandle(handle_0_0)
  452.     # Start of handle
  453.  
  454.     # Start user code
  455.     # End user code
  456.  
  457.     localvars = locals()
  458.     localvars.update(globals())
  459.     handle_0_1 = Handle(domHandler, localvars, onUnlink = lambda:None)
  460.  
  461.     handle_0.addSubHandle(handle_0_1)
  462.     # Start of handle
  463.  
  464.     # Start user code
  465.     # End user code
  466.  
  467.     localvars = locals()
  468.     localvars.update(globals())
  469.     handle_0_2 = Handle(domHandler, localvars, onUnlink = lambda:None)
  470.  
  471.     handle_0.addSubHandle(handle_0_2)
  472.     handle.addSubHandle(handle_0)
  473.  
  474.  
  475.     out = StringIO()
  476.     out.write(u"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n")
  477.     out.write(u'<html dtvPlatform="')
  478.     out.write(quoteattr(urlencode(dtvPlatform)))
  479.     out.write(u'" eventCookie="')
  480.     out.write(quoteattr(urlencode(eventCookie)))
  481.     out.write(u'" xmlns="http://www.w3.org/1999/xhtml">\n\n<head>\n    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"></meta>\n\n    <link href="')
  482.     out.write(quoteattr(resources.url(u'css/main.css')))
  483.     out.write(u'" type="text/css" rel="stylesheet"></link>\n    <script type="text/javascript">\n<!-- // Protect from our XML parser, which doesn\'t know to protect <script>\n\n///////////////////////////////////////////////////////////////////////////////\n//// For use on your page                                                  ////\n///////////////////////////////////////////////////////////////////////////////\n\nfunction getDTVPlatform() {\n    var elt = document.getElementsByTagName("html")[0];\n    return elt.getAttribute(\'dtvPlatform\');\n}\n\nfunction loadURL(url) {\n    try {\n        document.location.href = url;\n    } catch (e) {\n        // This may happen if the backend decides to handle the url load\n        // itself.\n    }\n}\n\n// For calling from page Javascript: Cause a URL to be loaded. The\n// assumption is that the application will notice, abort the load, and\n// take some action based on the URL.\nfunction eventURL(url) {\n    if (typeof(window.frontend) == \'undefined\') {\n\t// Generic strategy: trigger a load, and hope the application\n\t// catches it and cancels it without creating a race\n\t// condition.\n        loadURL(url)\n    } else {\n\t// OS X WebKit (KHTML) strategy: pass in an Objective C object\n\t// through the window object and call a method on it.\n\twindow.frontend.eventURL(url);\n    }\n\n    return false;\n}\n\n// Calls eventURL, then calls event.stopPropagation() and\n// event.preventDefault() so that the event chain is stopped.\nfunction eventURLAndStop(url, event) {\n  eventURL(url);\n  event.stopPropagation();\n  event.preventDefault();\n}\n\nfunction recommendItem(title, url) {\n    loadURL(\'http://www.videobomb.com/index/democracyemail?url=\' + \n            url + \'&title=\' + title);\n    return false;\n}\n\nfunction recommendChannel(title, url) {\n    // See also app.py if changing this URL\n    loadURL(\'http://www.videobomb.com/democracy_channel/email_friend\' +\n        \'?url=\' + url + \'&title=\' + title);\n    return false;\n}\n\n// Start the video player. The playlist will be the items in the view\n// named by viewName. If firstItemId is the id of an item in the view,\n// playback will start on that item; otherwise playback will start on\n// the first item.\nfunction playViewNamed(viewName, firstItemId) {\n    url = \'action:playViewNamed?\';\n    url = url + \'viewName=\' + URLencode(viewName);\n    url = url + \'&firstItemId=\' + URLencode(firstItemId);\n    eventURL(url);\n    return false;\n}\n\n// You can make \'incremental search\' text boxes on your page that\n// effectively tie the text box to the \'parameter\' argument of setViewFilter,\n// with the other argumens fixed. To do this, add these two attributes to\n// the text box:\n//   onfocus="startEditSearch(this)"\n//   onblur="endEditFilter()"\n// replacing the arguments in parentheses with the desired strings.\n//\n// You\'ll also need to provide a updateSearchString function at the\n// top of your template to perform the actual update\n\nvar editSearchField = null;\nvar editSearchOldValue = \'\';\nvar editSearchTimer = null;\nvar editSearchCallback = null;\n\nfunction onSearchFocus(obj){\n  if (obj.getAttribute(\'searching\') != \'1\') {\n\tobj.value="";\n\tobj.searching = \'1\';\n  }\n  startEditSearch(obj, null);\n}\n\nfunction startEditSearch(obj, callback) {\n  editSearchOldValue = obj.value;\n\n  editSearchField = obj;\n  editSearchCallback = callback;\n  editSearchTimerTick();\n}\n\nfunction editSearchUpdate() {\n    value = editSearchField.value;\n    if (editSearchOldValue != value) {\n\turl = \'action:setSearchString?searchString=\' + URLencode(value);\n\teventURL(url);\n\teditSearchOldValue = value;\n\tif(editSearchCallback) editSearchCallback();\n    }\n}\n\nfunction editSearchTimerTick() {\n    editSearchUpdate();\n    editSearchTimer = setTimeout(editSearchTimerTick, 50);\n}\n\nfunction endEditSearch() {\n  clearTimeout(editSearchTimer);\n  editSearchUpdate();\n}\n\n// Internal use: \'URL encode\' the given string.\nfunction URLencode(str) {\n    return encodeURIComponent(str)\n}\n\nfunction URLdecode(str) {\n  return decodeURIComponent(str)\n}\n\nvar currentSelectBoxMenu = null;\nfunction showSelectBoxMenu(id) {\n    document.getElementById(id).style.display = \'block\';\n    currentSelectBoxMenu = id;\n    document.addEventListener(\'click\', hideSelectBoxMenu, true)\n}\n\nfunction hideSelectBoxMenu(event) {\n    document.getElementById(currentSelectBoxMenu).style.display = \'\';\n    currentSelectBoxMenu = null;\n    document.removeEventListener(\'click\', hideSelectBoxMenu, true)\n}\n\n///////////////////////////////////////////////////////////////////////////////\n//// For calling by host templating code                                   ////\n///////////////////////////////////////////////////////////////////////////////\n\n// For calling by host templating code: Set CSS styles on the item\n// with the given ID to make it disappear.\nfunction hideItem(id) {\n    elt = document.getElementById(id);\n    elt.style.display = \'none\';\n    forceRedisplay(elt);\n}\n\n// For calling by host templating code: Set CSS styles on the item\n// with the given ID to make it visible if it was previously hidden.\nfunction showItem(id) {\n    elt = document.getElementById(id);\n    elt.style.display = \'\';\n    forceRedisplay(elt);\n}\n\n// For calling by host templating code: Replace the item with the\n// given id with the element described by the proided XML.\nfunction changeItem(id, newXML) {\n    elt = document.getElementById(id);\n    r = document.createRange();\n    r.selectNode(elt);\n    frag = r.createContextualFragment(newXML);\n    elt.parentNode.replaceChild(frag, elt);\n}\n\n// For calling by host templating code: Parse the XML in newXML into a\n// new element, and insert the new element immediately before the item\n// with the given id, such that the newly inserted item has the same\n// parent.\nfunction addItemBefore(newXML, id) {\n    elt = document.getElementById(id);\n    r = document.createRange();\n    r.selectNode(elt);\n    frag = r.createContextualFragment(newXML);\n    elt.parentNode.insertBefore(frag, elt);\n}    \n\n// For calling by host templating code: Parse the XML in newXML into a\n// new element, and insert the new element as the final child of the\n// item with the given id.\nfunction addItemAtEnd(newXML, id) {\n    elt = document.getElementById(id);\n    r = document.createRange();\n    r.selectNode(elt);\n    frag = r.createContextualFragment(newXML);\n    elt.insertBefore(frag, null);\n}    \n\n// For calling by host templating code: Remove the item with the given\n// id.\nfunction removeItem(id) {\n    elt = document.getElementById(id);\n    elt.parentNode.removeChild(elt);\n}    \n\n// Internal use: Sometime if all you do is change the style on a node,\n// Safari doesn\'t update the view until your mouse is next over the\n// window. Force the issue by making a drastic change in the vicinity\n// of the given element and then reversing it.\nfunction forceRedisplay(elt) {\n    r = document.createRange();\n    r.selectNode(elt);\n    frag = r.extractContents();\n    r.insertNode(frag);\n}\n\nfunction handleContextMenuSelect(event) {\n  if(event.button == 2) {\n    var area = event.currentTarget.getAttribute("selectArea");\n    var id = event.currentTarget.getAttribute("selectID");\n    var viewName = event.currentTarget.getAttribute("selectViewName");\n    var url = \'action:handleContextMenuSelect?id=\' + id + \'&area=\' + area +\n              \'&viewName=\' + viewName;\n    eventURL(url);\n  }\n  return true;\n}\n\nfunction handleSelect(event) {\n   if(event.target.tagName && event.target.tagName.toUpperCase() == \'A\') {\n       // Either a link in the descrption, or a bomb/mailto/trash click\n       return true;\n    }\n    var id = event.currentTarget.getAttribute("selectID");\n    var viewName = event.currentTarget.getAttribute("selectViewName");\n    var area = event.currentTarget.getAttribute("selectArea");\n    var shiftKey = \'0\';\n    var ctrlKey = \'0\';\n    if(event.shiftKey) shiftKey = \'1\';\n    if(event.ctrlKey || event.metaKey) ctrlKey = \'1\';\n    eventURL(\'action:handleSelect?area=\' + area + \'&viewName=\' + viewName + \n\t\'&id=\' + id + \'&shiftDown=\' + shiftKey + \'&ctrlDown=\' + ctrlKey);\n    return true;\n}\n\nfunction handleDblClick(event, viewName, id) {\n   var target = event.target;\n   while (target != undefined && target.ondblclick === null && target.tagName.toUpperCase() != \'A\') {\n       target = target.parentNode;\n   }\n\n   if(target.tagName.toUpperCase() == \'A\') {\n       // Either a link in the descrption, or a bomb/mailto/trash click\n       return true;\n   } else {\n       return eventURL(\'action:playViewNamed?viewName=\' + viewName + \n           \'&firstItemId=\' + id);\n   }\n}\n\nfunction getKeyFromEvent(evt) {\n  var key = 0;\n  if (window.event)  {\n    key = evt.keyCode;\n  } else if (evt.which) {\n  \tkey = evt.which;\n  }\n\n  return key;\n}\n\nfunction sendKeyToSearchBox(event) {\n  if(event.altKey || event.ctrlKey || event.metaKey ||\n      (event.target.tagName && event.target.tagName.toUpperCase() == \'INPUT\'))\n      return true;\n  var key = getKeyFromEvent(event);\n  if ((key == 33) || (key == 34) || (key == 35) || (key == 36) || \n      (key == 37) || (key == 38) || (key == 39) || (key == 40))\n      return true;\n  var searchBox = document.getElementById("search-box");\n  searchBox.focus();\n  return true;\n}\n\nfunction playNewVideos(event, id) {\n  eventURL(\'action:playNewVideos?id=\' + id);\n  event.stopPropagation(); // don\'t want handleSelect to deal with this event\n  return false;\n}\n\n///////////////////////////////////////////////////////////////////////////////\n///////////////////////////////////////////////////////////////////////////////\n\n-->\n</script>\n\n    <script src="')
  484.     out.write(quoteattr(resources.url(u'templates/osxdnd.js')))
  485.     out.write(u'" type="text/javascript"></script>\n    \n    \n</head>\n\n<body dragdesttype="channel" drageffectchannel="move" dragdestdata="channelfolder-')
  486.     out.write(quoteattr(folder.getID()))
  487.     out.write(u'" onkeydown="sendKeyToSearchBox(event);"')
  488.     out.write(u" " + bodyTagExtra)
  489.     out.write(u'>\n<div id="main-titlebar">\n    <img src="')
  490.     out.write(quoteattr(resources.url(u'images/folder-icon.png')))
  491.     out.write(u'" alt="" id="main-icon"></img>\n    ')
  492.     out.write(u'<span id="tmplcomp79163633"/>\n</div>\n<div id="main-container">\n    ')
  493.     out.write(u'\n\n')
  494.     out.write(u'<span id="tmplcomp42456820"/>\n\n    ')
  495.     out.write(u'<span id="tmplcomp44566956"/>\n    <div id="tmplcomp26851151">')
  496.     out.write(u'</div>\n\n\n\n\n\n<div class="available-channelbar-wrap">\n    ')
  497.     out.write(u'<span id="tmplcomp17163270"/>\n</div>\n\n')
  498.     out.write(u'<span id="tmplcomp06046450"/>\n\n<div id="tmplcomp33017135">')
  499.     out.write(u'</div>\n\n\n')
  500.     out.write(u'<span id="tmplcomp78307766"/>\n\n\n\n\n<div id="tmplcomp91926686"')
  501.     _hideFunc = lambda : not isFolder and feed.getURL().startswith('dtv:directoryfeed')
  502.     _dynHide = _hideFunc()
  503.     if _dynHide:
  504.         out.write(u" style=\"display:none\">")
  505.     else:
  506.         out.write(u">")
  507.     handle.addUpdateHideOnView('tmplcomp91926686',thisFeedView,_hideFunc,_dynHide)
  508.     out.write(u'\n    ')
  509.     out.write(u'<span id="tmplcomp24866162"/>\n    \n    ')
  510.     out.write(u'<span id="tmplcomp45222576"/>\n    <div id="tmplcomp41906179">')
  511.     out.write(u'</div>\n</div>\n\n\n')
  512.     out.write(u'\n</div>\n')
  513.     out.write(u'<span id="tmplcomp05902902"/>\n</body>\n</html>')
  514.     out.seek(0)
  515.  
  516.  
  517.     return (out, handle)
  518.